//
//#include "SDL.h"
//#include <string>
//#include "sdl_image.h"
//#include "tileManager.h"
//#include "Draw.h"
//#include "Drawable.h"
//#include "Player.h"
//#include "Wall.h"
//#include "floor.h"
//#include "Levels.h"
////The surfaces that will be used
//SDL_Surface *message = NULL;
//SDL_Surface *tileset = NULL;
//SDL_Surface *screen = NULL; 
//SDL_Rect *leftPane= NULL;
//SDL_Rect *rightPane=NULL;
//SDL_Surface *map = NULL;
//int main( int argc, char* args[] )
//{	
//	bool gameOver = false;
//	IMG_INIT_PNG;
//	SDL_Init(SDL_INIT_VIDEO);
//	Drawable d =* new Drawable();
//
//	//Initialize all SDL subsystems
//	if( SDL_Init( SDL_INIT_EVERYTHING ) == -1 )
//	{
//		return 1;
//	}
//
//	//Set up the screen
//	screen = SDL_SetVideoMode( TileManager::SCREEN_WIDTH*2, TileManager::SCREEN_HEIGHT, TileManager::SCREEN_BPP, SDL_SWSURFACE );
//
//	rightPane = new SDL_Rect(screen->clip_rect);
//	leftPane = new SDL_Rect(screen->clip_rect);
//	/*create panes*/
//	leftPane->w /= 2; 
//	rightPane->w /=2; 
//	rightPane->x = leftPane->w;  
//
//	//If there was an error in setting up the screen
//	if( screen == NULL )
//	{
//		return 1;
//	}
//	map = new SDL_Surface();
//
//
//
//	//draw black to the screen before we begin
//	SDL_FillRect( screen, &screen->clip_rect, SDL_MapRGB( screen->format, 0xff, 0xff, 0xff ) );
//
//
//	SDL_FillRect( screen, rightPane, SDL_MapRGB( screen->format, 0xff, 0xff, 0x00 ) );
//	SDL_FillRect( screen, leftPane, SDL_MapRGB( screen->format, 0xff, 0x00, 0xFF ) );
//	//Set the window caption
//	SDL_WM_SetCaption( "ROGUELIKELIKE MAP EDITOR - THE MAP EDITORLIKE", NULL );
//
//
//	tileset = Draw::load_image("tileset.gif");
//	if(tileset==NULL)
//		return 1;
//
//	//full power to the TileManager
//	TileManager *tm = new TileManager(tileset, screen); 
//	Draw::apply_surface(0,0,tileset,screen,leftPane);
//	SDL_Event event=*new SDL_Event();
//
//	int x = 0;
//	int y = 0;
//	int activePaint = 0;
//	bool mouseDown = false;
//	//BEGIN GAME LOOP
//	while(!gameOver){
//		/*HEY BITCH. YOU HAVE HUGE MEMORY LEAKS BECAUSE YOU'RE BAD AND YOU DON"T OVERRIDE THE BIG THREE. OVERRIDE ALL OF YOUR DESTRUCTORS SO YOU AREN"T USING 1GB OF MEMORY AFTER 3 MOVES DUMBASS
//
//		*/
//
//		//SDL_FillRect( screen, &screen->clip_rect, SDL_MapRGB( screen->format, 0x00, 0x00, 0x00 ) );//"resets" the screen so we don't get weird behavior with alpha
//		SDL_WaitEvent(&event);
//
//		//If a key was pressed
//		if( event.type == SDL_KEYDOWN )
//		{ 
//
//			switch( event.key.keysym.sym )
//			{
//				//need a class to store keys generically so user can set them,
//
//			case SDLK_q:gameOver = true; break;
//			default:break;  
//			}
//		}
//
//		if( event.type == SDL_MOUSEBUTTONDOWN )
//		{
//			//If the left mouse button was pressed
//			if( event.button.button == SDL_BUTTON_LEFT )
//			{
//				//Get the mouse offsets
//				x = event.button.x;
//				y = event.button.y;
//				if(x<leftPane->x+leftPane->w)//then we must be inside of left pane
//				{
//					activePaint = tm->getIndex(x,y,1);
//					//need to preload information about game objects. or something.
//					//right now we're like one of those kids with a pretend cell phone.
//					//just drawing fake maps that don't do shit.
//
//				}
//				else//we must be inside right pane. paint
//				{
//					mouseDown = true;
//					//x-=leftPane->w; //now the upper left of the right pane is 'zero'
//					x/=tm->TILE_SIZE;
//					y/=tm->TILE_SIZE;
//					x = x*tm->TILE_SIZE;
//					y = y*tm->TILE_SIZE;
//					Draw::apply_surface(x,y, tileset,screen, &tm->images[activePaint]);
//				}
//				//note that we should be checking EXPLICITLY whether it is inside these rects.
//				//if we ever add extra panes or buttons this w ill be fucked.
//			}
//		}
//		if(mouseDown)
//		{
//
//			x/=tm->TILE_SIZE;
//			y/=tm->TILE_SIZE;
//			x = x*tm->TILE_SIZE;
//			y = y*tm->TILE_SIZE;
//			Draw::apply_surface(x,y, tileset,screen, &tm->images[activePaint]);
//			if( event.type == SDL_MOUSEMOTION )
//			{
//				//Get the mouse offsets
//				x = event.motion.x;
//				y = event.motion.y;
//				if(x<leftPane->x+leftPane->w)//then we must be inside of left pane
//				{
//					activePaint = tm->getIndex(x,y,1);
//					//need to preload information about game objects. or something.
//					//right now we're like one of those kids with a pretend cell phone.
//					//just drawing fake maps that don't do shit.
//
//				}
//				else//we must be inside right pane. paint
//				{
//
//					//x-=leftPane->w; //now the upper left of the right pane is 'zero'
//					x/=tm->TILE_SIZE;
//					y/=tm->TILE_SIZE;
//					x = x*tm->TILE_SIZE;
//					y = y*tm->TILE_SIZE;
//					Draw::apply_surface(x,y, tileset,screen, &tm->images[activePaint]);
//
//
//				}
//			}
//		}
//		if( event.type == SDL_MOUSEBUTTONUP )
//    {
//        //If the left mouse button was released
//        if( event.button.button == SDL_BUTTON_LEFT )
//        { 
//			mouseDown = false;
//		}
//
//	}
//
//		//If the user has Xed out the window
//		else if( event.type == SDL_QUIT )
//		{
//			//Quit the program
//			gameOver = true;
//		}
//
//
//
//		//Update the screen
//		//		tm->update();
//		//Draw::apply_surface(rightPane->x,0, map,screen);
//		if( SDL_Flip( screen ) == -1 )
//		{
//			return 1;    
//		}
//	}//end of gameloop 
//
//	//Free the surfaces
//	SDL_FreeSurface( message );
//	SDL_FreeSurface( tileset );
//
//	//Quit SDL
//	SDL_Quit();
//
//	return 0;
//}
//
